package com.ruoyi.weika.controller;

import com.ruoyi.common.core.controller.BaseController;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/weika/auth")
public class WeikaAuthController extends BaseController {


    @ResponseBody
    @PostMapping(value = "/callback")
    public String callback(final HttpServletRequest request,
                           @RequestParam(name = "msg_signature") final String sMsgSignature,
                           @RequestParam(name = "timestamp") final String sTimestamp,
                           @RequestParam(name = "nonce") final String sNonce) {

        try {
            /*
             InputStream inputStream = request.getInputStream();
            String sPostData = IOUtils.toString(inputStream, "UTF-8");
            WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(token,corpid, encodingAesKey);
            //解密
            String sMsg = msgCrypt.decryptMsg(msgSignature, timeStamp, String nonce, postData);
            //将post数据转换为map
            Map<String, String> dataMap = MessageUtil.parseXml(sMsg);
            //然后去操作你的业务逻辑
            * */

        } catch (Exception e) {
            e.printStackTrace();
        }
        return "success";
    }

}
